#ifndef DTWENTYMODEL_H
#define DTWENTYMODEL_H


#include "dtwenty_global.h"
#include "dtwentyitem.h"
#include "dtwentyitemcontainer.h"


#include <itemtreemodel.h>


Q_DECLARE_METATYPE(QPersistentModelIndex)


class DTWENTYSHARED_EXPORT DTwentyModel : public ItemTreeModel
{
    Q_OBJECT

public:

    enum ValueType
    {
        ValueType_NORMAL,
        ValueType_SELECTION
    };

    enum DTwentyBaseType
    {
        DTwentyBaseType_ITEM = 0,
        DTwentyBaseType_CONTAINER
    };

    enum Role
    {
        Role_FIRST = ItemTreeModel::Role_LAST + 1,

        Role_DTWENTY_BASETYPE = Role_FIRST,
        Role_CHILD_TYPE,
        Role_CHILD_TYPENAME,
        Role_VALUE_TYPE,
        Role_VALUE_SOURCE,
        Role_VALUE_OPTIONS,

        Role_LAST = Role_VALUE_OPTIONS
    };

    explicit DTwentyModel(QObject *parent = 0);


    virtual QVariant data(const QModelIndex &index, int role) const;
    virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role);

    virtual bool insertRows(int row, int count, const QModelIndex &parent);
    virtual bool removeRows(int row, int count, const QModelIndex &parent);

    virtual Qt::ItemFlags flags(const QModelIndex &index) const;


    QVariantMap characterClasses() const;


protected:

    static DTwentyItem* itemFromIndex(const QModelIndex& index);
    static DTwentyItemContainer* containerFromIndex(const QModelIndex& index);

    static QString propertyName(const QModelIndex& index);



};


#endif // DTWENTYMODEL_H


